.TH std::from_range,std::from_range_t 3 "2024.06.10" "http://cppreference.com" "C++ Standard Libary"
.SH NAME
std::from_range,std::from_range_t \- std::from_range,std::from_range_t

.SH Synopsis
   Defined in header <ranges>
   struct from_range_t { explicit from_range_t() = default; };  (since C++23)
   inline constexpr std::from_range_t from_range {};            (since C++23)

   std::from_range is a disambiguation tag that can be passed to the constructors of
   the suitable containers to indicate that the contained member is range constructed.

   The corresponding type std::from_range_t can be used in the constructor's parameter
   list to match the intended tag.

.SH Standard library

   The following standard library types use std::from_range_t type in their
   constructors:

.SH Containers library
   constructor   constructs the vector from a range
   (C++23)       \fI(public member function of std::vector<T,Allocator>)\fP
   constructor   constructs the deque from a range
   (C++23)       \fI(public member function of std::deque<T,Allocator>)\fP
   constructor   constructs the forward_list from a range
   (C++23)       \fI(public member function of std::forward_list<T,Allocator>)\fP
   constructor   constructs the list from a range
   (C++23)       \fI(public member function of std::list<T,Allocator>)\fP
   constructor   constructs the set from a range
   (C++23)       \fI(public member function of std::set<Key,Compare,Allocator>)\fP
   constructor   constructs the map from a range
   (C++23)       \fI(public member function of std::map<Key,T,Compare,Allocator>)\fP
   constructor   constructs the multiset from a range
   (C++23)       \fI(public member function of std::multiset<Key,Compare,Allocator>)\fP
   constructor   constructs the multimap from a range
   (C++23)       \fI(public member function of std::multimap<Key,T,Compare,Allocator>)\fP
   constructor   constructs the unordered_set from a range
   (C++23)       \fI\fI(public member\fP function of\fP
                 std::unordered_set<Key,Hash,KeyEqual,Allocator>)
   constructor   constructs the unordered_map from a range
   (C++23)       \fI\fI(public member\fP function of\fP
                 std::unordered_map<Key,T,Hash,KeyEqual,Allocator>)
   constructor   constructs the unordered_multiset from a range
   (C++23)       \fI\fI(public member\fP function of\fP
                 std::unordered_multiset<Key,Hash,KeyEqual,Allocator>)
   constructor   constructs the unordered_multimap from a range
   (C++23)       \fI\fI(public member\fP function of\fP
                 std::unordered_multimap<Key,T,Hash,KeyEqual,Allocator>)
   constructor   constructs the priority_queue from a range
   (C++23)       \fI(public member function of std::priority_queue<T,Container,Compare>)\fP
   constructor   constructs the queue from a range
   (C++23)       \fI(public member function of std::queue<T,Container>)\fP
   constructor   constructs the stack from a range
   (C++23)       \fI(public member function of std::stack<T,Container>)\fP
   constructor   constructs the flat_set from a range
   (C++23)       \fI(public member function of std::flat_set<Key,Compare,KeyContainer>)\fP
   constructor   constructs the flat_map from a range
   (C++23)       \fI\fI(public member\fP function of\fP
                 std::flat_map<Key,T,Compare,KeyContainer,MappedContainer>)
   constructor   constructs the flat_multiset from a range
   (C++23)       \fI\fI(public member\fP function of\fP
                 std::flat_multiset<Key,Compare,KeyContainer>)
   constructor   constructs the flat_multimap from a range
   (C++23)       \fI\fI(public member\fP function of\fP
                 std::flat_multimap<Key,T,Compare,KeyContainer,MappedContainer>)
.SH Strings library
   constructor   constructs the basic_string from a range
   (C++23)       \fI(public member function of std::basic_string<CharT,Traits,Allocator>)\fP

.SH Notes

       Feature-test macro       Value    Std                   Feature
   __cpp_lib_containers_ranges 202202L (C++23) Tagged constructors to construct from
                                               container compatible range

.SH Example


// Run this code

 #include <cassert>
 #include <string>

 int main()
 {
 #ifdef __cpp_lib_containers_ranges
     auto const range = {0x43, 43, 43};
     std::string str{std::from_range, range}; // uses tagged constructor
     assert(str == "C++");
 #endif
 }

.SH See also

   in_place
   in_place_type
   in_place_index      in-place construction tag
   in_place_t          (tag)
   in_place_type_t
   in_place_index_t
   \fI(C++17)\fP
   sorted_equivalent   indicates that elements of a range are sorted (uniqueness is not
   sorted_equivalent_t required)
   (C++23)             (tag)
   sorted_unique       indicates that elements of a range are sorted and unique
   sorted_unique_t     (tag)
   (C++23)
   ranges::to          constructs a new non-view object from an input range
   (C++23)             \fI(function template)\fP
